﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataAccessObject;
using EntityObject;
using ThangNM_LIB.FUNC;
using ThangNM_LIB.EO;

namespace CSharp
{
    public partial class HotDeal : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //ListBox1.GetSelectedIndices
                String sSID = Convert.ToString(RouteData.Values["sSID"]);
                if (!String.IsNullOrEmpty(sSID))
                {
                    HotDealEO objTemp = new HotDealEO();
                    KeyValueEO objKV = new KeyValueEO(null, sSID);
                    objKV = OtherEx.ConvertNumberToChar(objKV);
                    if (objKV != null && StringEx.IsNumeric(objKV.K, TypeCode.Int64))
                    {
                        objTemp.PK_iDID = Convert.ToInt64(objKV.K);
                        objTemp = (new HotDealDAO()).SelectItem(objTemp);
                        if (objTemp != null && objTemp.PK_iDID > 0)
                        {
                            if (!StringEx.Compare(Request.RawUrl.Substring(1), objTemp.sUrlRewrite))
                            {
                                OtherEx.setRedirect(Page, objTemp.sUrlRewrite);
                                return;
                            }
                            ItemUC1.BindData(objTemp, objTemp.sContent);
                            return;
                        }
                    }
                }
            }
            lblMsg.Text = "Trang không tồn tại hoặc đường dẫn không đúng.";
        }
    }
}